import gmpy2
import libnum

n2 = 127003138248767878216087746092048765422017641585502083524432000355338408532541607865197910579606631797065299031898223525594806324068716151137783179018112665582625201123056770957620662712083897966775244206284988606422553807186125185230229622748491730778439493335081760134674989431869363324785659619359492375443
x2 = 3713689996494536207275880780575695141387196713829050036258614350034484757813937841042992412600156055738200137589955494058780961235985782374795104819263776
x2 = bin(x2)[2:].zfill(512)

pre_sol = [(0, 0)]
for x in range(256):
    cur_sol = []
    for p, q in pre_sol:
        for i in range(2):
            for j in range(2):
                cur_p = p + i * pow(2, 511 - x) + (int(x2[x]) ^ j) * pow(2, x)
                cur_q = q + j * pow(2, 511 - x) + (int(x2[511 - x]) ^ i) * pow(2, x)

                if cur_p * cur_q > n2:
                    continue
                if (cur_p + pow(2, 511 - x)) * (cur_q + pow(2, 511 - x)) < n2:
                    continue
                if (cur_p * cur_q) % pow(2, x + 1) != n2 % pow(2, x + 1):
                    continue
                cur_sol.append((cur_p, cur_q))
    pre_sol = cur_sol
for p, q in pre_sol:
    if p * q == n2:
        print(p, q)
        break

n=n2
e=65537
c=28606725830066334603624115469720836321272317195642525617463167689108174235290116089778712864587832608893147665928536755331808728420928314539950719845140223156504618276048603869925007708152189255298965799947640133200085111741254836861931603704948557525706684578721413729858589789350780583640229671796472384358
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
m=pow(c,d,n)
print(libnum.n2s(int(m)))